Component({
  properties: {
    show: {
      type: Boolean,
      value: false
    },
    basicInfo: {
      type: Object,
      value: {}
    }
  },
  methods: {
    changeInput ({ detail }) {
      this.setData({ 'basicInfo.value': detail.value })
    },
    close () {
      this.triggerEvent('close')
    },
    confirm () {
      if (!this.data.basicInfo.value) {
        wx.showToast({ title: '请输入要修改的信息！', icon: 'none' })
        return
      }
      let emailReg = /^[A-Za-z\d]+([-_.][A-Za-z\d]+)*@([A-Za-z\d]+[-.])+[A-Za-z\d]{2,5}$/
      if (this.data.basicInfo.key === 'mail' && !emailReg.test(this.data.basicInfo.value)) {
        wx.showToast({ title: '邮箱格式不正确！', icon: 'none' })
        return
      }
      this.triggerEvent('change', this.data.basicInfo)
    }
  },
})